package org.gd.hellojaxb.privat24.statements;

import org.gd.hellojaxb.adapters.DateAdaptersFactory;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "mes")
public class RequestToIQ {

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlRootElement(name = "period")
    public static final class RequestToIQPeriod {

        @XmlAttribute(name = "date1", required = true)
        @XmlJavaTypeAdapter(DateAdaptersFactory.StatementsDateFormat.class)
        private Date date1;

        @XmlAttribute(name = "date2", required = true)
        @XmlJavaTypeAdapter(DateAdaptersFactory.StatementsDateFormat.class)
        private Date date2;

        private RequestToIQPeriod() {

        }

        private RequestToIQPeriod(Date date1, Date date2) {
            this.date1 = date1;
            this.date2 = date2;
        }

        public Date getDate1() {
            return date1;
        }

        public void setDate1(Date date1) {
            this.date1 = date1;
        }

        public Date getDate2() {
            return date2;
        }

        public void setDate2(Date date2) {
            this.date2 = date2;
        }
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlRootElement(name = "pan")
    public static final class RequestToIQCard {

        @XmlAttribute(name = "pan", required = true)
        private String number;

        private RequestToIQCard() {

        }

        private RequestToIQCard(String number) {
            this.number = number;
        }

        public String getNumber() {
            return number;
        }

        public void setNumber(String number) {
            this.number = number;
        }
    }

    @XmlElement(name = "period")
    private RequestToIQPeriod period;
    @XmlElement(name = "pan")
    private RequestToIQCard card;

    public RequestToIQ() {

    }

    public RequestToIQ(Date date1, Date date2, String card) {
        this.period = new RequestToIQPeriod(date1, date2);
        this.card = new RequestToIQCard(card);
    }

    public RequestToIQPeriod getPeriod() {
        return period;
    }

    public void setPeriod(RequestToIQPeriod period) {
        this.period = period;
    }

    public RequestToIQCard getCard() {
        return card;
    }

    public void setCard(RequestToIQCard card) {
        this.card = card;
    }
}
